package Try;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main9 {
    public static void main(String[] args) throws IOException {
        BufferedReader readerPerson = getReader("C:\\Users\\ruanjie\\Desktop\\viton_person.txt");
        BufferedReader readerCloth = getReader("C:\\Users\\ruanjie\\Desktop\\viton_cloth.txt");
        String person;
        String cloth;
        List<String> personList = new ArrayList<>();
        List<String> clothList = new ArrayList<>();
        while ((person=readerPerson.readLine())!=null){
            String[] strs = person.split(" ");
            personList.add(strs[0]);
        }

        while ((cloth=readerCloth.readLine())!=null){
            String[] strs = cloth.split(" ");
            clothList.add(strs[1]);
        }

        BufferedWriter writer = getWriter("C:\\Users\\ruanjie\\Desktop\\viton_mix.txt");
        System.out.println(clothList.size());
        for (int i=0;i<personList.size();i++){
            for (int j=0;j<clothList.size();j++){
                System.out.println(personList.get(i)+" "+clothList.get(j));
                writer.write(personList.get(i)+" "+clothList.get(j)+"\t\n");
            }
        }
        writer.close();

    }

    public static BufferedReader getReader(String str) throws FileNotFoundException {
        File file = new File(str);
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        return reader;
    }

    public static BufferedWriter getWriter(String str) throws FileNotFoundException {
        File file = new File(str);
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
        return writer;
    }



}
